/*
* 用户有关访问接口数据
*/
import { setCommonSystemLoading, setCommonDate } from './Action';
import * as DataName from './DataNameConfig';
import { ORDER_API_TYPE } from "../utils/Api";
import Util from '../utils/Util';
import HttpServer from '../axios';

/**
 * 订单列表
 * @param {Object} filter
 */
export const GetOrderList =(filter)=> {
    return dispatch=>{
        HttpServer(Util.getApi(ORDER_API_TYPE,"OrderList"),filter)
            .then((res)=>{
                dispatch(setCommonSystemLoading(DataName.ORDER_LIST_CARD_LOADING,false));
                dispatch(setCommonSystemLoading(DataName.BASE_TABLE_LOADING,false));
                res.result.filter = filter;
                dispatch(setCommonDate('set_base_data',DataName.ORDER_LIST,res.result))
            },(error)=>{
                dispatch(setCommonSystemLoading(DataName.BASE_TABLE_LOADING,false));
                console.log(error)
            })
    }
}

/**
 * 更新发货信息
 * @param {Object} filter
 * @param {Object} fil
 */
export const GetSendPackage =(filter,fil)=> {
    return dispatch=>{
        HttpServer(Util.getApi(ORDER_API_TYPE,"SendPackage"),filter)
            .then((res)=>{
                dispatch(setCommonSystemLoading(DataName.FORM_SPIN_LOADING,false));
                dispatch(setCommonSystemLoading(DataName.BASE_MODAL,false));
                dispatch(setCommonSystemLoading(DataName.ORDER_LIST_CARD_LOADING,true));
                dispatch(GetOrderList({...fil}));
            },(error)=>{
                dispatch(setCommonSystemLoading(DataName.FORM_SPIN_LOADING,false));
                console.log(error)
            })
    }
}

